<?php
/**
 * @ClassName: Callback
 * @Description: 回调通知
 * @author: wyaohu
 * @Date: 2025-07-23 17:06
 * @Version: V1.0.0
 */

namespace app\meituan\controller;

use app\meituan\logic\BasicLogic;

class Callback
{
    /**
     * 回调通知
     * @return \think\response\Json
     */
    public function notify()
    {
        // 1.接收参数
        $data = input();

        // 写入日志
        $log = '回调通知：' . json_encode($data, 320) . "\n";
        makelog($log, 'api/meituan/notify');

        // 2.验证签名
        $res = (new BasicLogic())->checkSign($data);
        if (!$res) {
            makelog("签名验证失败", 'api/meituan/notify');
            return json(["code" => -1, "message" => "验证签名失败"]);
        }
        makelog("签名验证成功", 'api/meituan/notify');
        return json(["code" => 0, "message" => "验证签名成功"]);
    }

}